package org.example

import org.apache.spark.sql.SparkSession

object sparkData2 {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession
      .builder()
      .master("local[*]")
      .getOrCreate()
    val sc = spark.sparkContext
    //英文分词
    sc.textFile("src/main/resources/word.txt")
      .flatMap(_.split(""))
      .map(x => (x,1))
      .reduceByKey((x,y) => x + y)
      .foreach(println)
    //中文分词
//    val word1 = HanLP.segment("清明时节雨纷纷，路上行人梳中分。")
//    println(word1)
//    println(word1.asScala.map(_.word.trim))
    sc.stop()
  }

}
